package mtm.ui.misc;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;

public class TimeComboBox extends JComboBox {

	
	private DefaultComboBoxModel model;

	/**
	 * Constructor
	 */
	public TimeComboBox() {
		super();
		
		String[] timeData = new String[49];
		int i = 0;
		for (int h = 0; h < 24; ++h) {
			for (int m = 0; m < 2; ++m) {
				timeData[i++] = (h < 10 ? "0" + h : h) + ":" + (m == 0 ? "00" : "" + m * 30);
			}
		}
		timeData[timeData.length - 1] = "23:59";
		
		model = new DefaultComboBoxModel(timeData);
		setModel(model);
	}
	
	
	/**
	 * Set the current displayed text 
	 */
	public void setText(String text) {
		model.setSelectedItem(text);
	}
}
